<html xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui" >  

    <ui:composition template="layout.xhtml">

        <ui:define name="corpo">
            <h:form>
                <div id="breadcrumb">
                    <p:commandLink  actionListener="#{managerIndex.redirect('index.xhtml')}" value="Inicio" update="@form" immediate="true"/> >
                    <p:commandLink  value="Protocolo" update="@form" immediate="true"/>

                </div>

            </h:form>
            <p:panel header="Principal - Protocolo">
                <table style="min-height:500px; width: 100%">
                    <tr>
                        <td style="width: 200px; vertical-align:top;">
                            <ui:include src="menuProtocolo.xhtml"/>
                        </td>
                        <td style="vertical-align:top;">
                            <h:form id="index_form" style="vertical-align: top" acceptcharset="utf-8"> 
                                <f:validateBean disabled="true">
                                    <p:poll interval="25" immediate="true"
                                        listener="#{managerIndexProtocolo.poll()}"
                                        update="protocoloTable, pagamentoTable, finalTable" /> 
                                </f:validateBean>
                                  
                                <fieldset  style="width: 97%">
                                    <legend>Protocolos Recentes</legend> 
                                    <h:panelGrid columns="2" style="width:100%;">

                                        <p:dataTable id="protocoloTable" var="pro" value="#{managerIndexProtocolo.protocolosRec}" 
                                                     paginator="true" rows="5" style="width: 100%" 
                                                     paginatorPosition="bottom" 
                                                     rowIndexVar="rowid" 
                                                     rowKey="#{pro.id}" selectionMode="single" 
                                                     emptyMessage="Nenhum Protocolo Recente"
                                                     paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"  
                                                     rowsPerPageTemplate="5,10,15">    

                                            

                                            <p:column   style="width:20px;">  
                                                <p:commandButton style="width:20px; height: 20px;" icon="ui-icon-search" title="Ver" label="Ver"
                                                                 actionListener="#{managerVisualizarProtocolo.ver(pro.id)}" 
                                                                 update="@form"/>
                                            </p:column>
                                            <p:column style="width:20px;" >  
                                                <f:facet name="header" >   
                                                    Cód.
                                                </f:facet>  
                                                <h:outputText value="#{pro.id}" 
                                                              />  
                                            </p:column>
                                            <p:column >  
                                                <f:facet name="header" >   
                                                    Nome
                                                </f:facet>  
                                                <h:outputText value="#{pro.cliente.nome}"  />  
                                            </p:column>


                                        </p:dataTable> 

                                    </h:panelGrid>
                                </fieldset>
                                <br/>

                                <h:panelGrid columns="2" style="width: 100%" columnClasses="top, top">
                                    <p:row >
                                        <fieldset>
                                            <legend>Protocolos Pendentes</legend> 
                                            <p:dataTable id="pagamentoTable" var="prop" value="#{managerIndexProtocolo.protocolosPendentes}" 
                                                         paginator="true" rows="5"
                                                         paginatorPosition="bottom" rowIndexVar="rowid" 
                                                         rowKey="#{prop.id}" selectionMode="single" emptyMessage="Nenhum Protocolo Pendente"
                                                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"  
                                                         rowsPerPageTemplate="5,10,15">    

                                                <p:column   style="width:20px;">  
                                                    <p:commandButton style="width:20px; height: 20px;" icon="ui-icon-search" title="Ver" label="Ver"
                                                                     actionListener="#{managerVisualizarProtocolo.ver(prop.id)}" 
                                                                     update="@form"/>
                                                </p:column>

                                                <p:column style="width:20px;" >  
                                                    <f:facet name="header" >   
                                                        Cód.
                                                    </f:facet>  
                                                    <h:outputText value="#{prop.id}" 
                                                                  />  
                                                </p:column>
                                                <p:column >  
                                                    <f:facet name="header" >   
                                                        Nome
                                                    </f:facet>  
                                                    <h:outputText value="#{prop.cliente.nome}"  />  
                                                </p:column>
                                                <p:column style="width: 50px" >     
<!--                                                    <p:graphicImage url="/media/img/money.png" 
                                                                    rendered="{managerConsultarProtocolo.pendentePagamento(prop.id)}"
                                                                    title="Pagamento Pendente" />-->
                                                    <p:graphicImage url="/media/img/selo.jpg" style="width:24px; margin-left: 10px; "
                                                                    rendered="#{managerConsultarProtocolo.pendenteSelo(prop.id)}"
                                                                    title="Selos Pendente" />
                                                </p:column>

                                            </p:dataTable> 
                                        </fieldset>
                                    </p:row>
                                    <p:row>
                                        <fieldset>
                                            <legend>Protocolos Finalizados</legend> 

                                            <p:dataTable id="finalTable" var="prof" value="#{managerIndexProtocolo.protocolosFinal}" 
                                                         paginator="true" rows="5" 
                                                         rowIndexVar="rowid" 
                                                         rowKey="#{prof.id}" selectionMode="single" 
                                                         paginatorPosition="bottom" emptyMessage="Nenhum Protocolo Finalizado"
                                                         paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"  
                                                         rowsPerPageTemplate="5,10,15">    

                                                <p:column   style="width:20px;">  
                                                    <p:commandButton style="width:20px; height: 20px;" icon="ui-icon-search" title="Ver" label="Ver"
                                                                     actionListener="#{managerVisualizarProtocolo.ver(prof.id)}" 
                                                                     update="@form"/>
                                                </p:column>
                                                <p:column style="width:20px;" >  
                                                    <f:facet name="header" >   
                                                        Cód.
                                                    </f:facet>  
                                                    <h:outputText value="#{prof.id}" 
                                                                  />  
                                                </p:column>
                                                <p:column >  
                                                    <f:facet name="header" >   
                                                        Nome
                                                    </f:facet>  
                                                    <h:outputText value="#{prof.cliente.nome}"  />  
                                                </p:column>

                                            </p:dataTable> 
                                        </fieldset>
                                    </p:row>
                                </h:panelGrid>

                            </h:form>

                        </td>
                    </tr>
                </table>
            </p:panel>
        </ui:define>
    </ui:composition>
</html>
